﻿namespace ALDIOrganizer
{
    public partial class MainForm
    {
        private void CurrentFile_OnTemplatesCollectionModified()
        {
            var value = cbTemplate.SelectedValue;
            cbTemplate.Tag = true; // ignore SelectedValueChanged
            cbTemplate.DataSource = Program.CurrentFile.TemplatesDataSource;
            cbTemplate.Tag = false; // stop ignoring SelectedValueChanged
            cbTemplate.GoTo(value);
        }

        private void CurrentFile_OnRotasCollectionModified()
        {
            sheetCalendar.DataSource = null;
            cbWeek.Tag = true;
            cbWeek.DataSource = null;
            sheetCalendar.DataSource = Program.CurrentFile.RotasDataSource;

            cbWeek.DisplayMember = "Key";
            cbWeek.ValueMember = "Value";
            cbWeek.DataSource = Program.CurrentFile.WeeksDataSource;
            AdjustcbWeekValue();
            cbWeek.Tag = false;
            
            SetEnabledForJumpingButtons();
        }
    }
}
